package dtd.PHS.VND_ExchangeRate.widget;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import dtd.PHS.VND_ExchangeRate.utils.Helpers;
import dtd.PHS.VND_ExchangeRate.utils.Logger;
import dtd.PHS.VND_ExchangeRate.utils.PreferencesHelpers;

public class NetworkConnectionReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		Logger.logInfo("Network changed !");
		Helpers.initGlobalData(context);
		if ( PreferencesHelpers.isTobeUpdatedByInternet() && 
				Helpers.isConnectedToInternet() && 
				!Helpers.isFirstTimeRunning()) {
			Logger.logInfo("Connected 2 internet ");
			Intent i = new Intent(context,UpdateWidgetService.class);
			context.startService(i);
		}
	}

}
